interface Date {
  format: (f: any) => Date
  getNowDate: () => String
}
interface Array<T> {
  contains: (param: any) => boolean
  remove: (param: any) => void
}
//增强基本语法
Date.prototype.format = function(format) {
  var o = {
   "M+" : this.getMonth()+1, //month
   "d+" : this.getDate(),    //day
   "h+" : this.getHours(),   //hour
   "m+" : this.getMinutes(), //minute
   "s+" : this.getSeconds(), //second
   "q+" : Math.floor((this.getMonth()+3)/3),  //quarter
   "S" : this.getMilliseconds() //millisecond
  }
  if(/(y+)/.test(format)) 
    format=format.replace(RegExp.$1,(this.getFullYear()+"").substr(4 - RegExp.$1.length))
  for(var k in o)
    if(new RegExp("("+ k +")").test(format))
      format = format.replace(RegExp.$1,RegExp.$1.length==1 ? o[k] :("00"+ o[k]).substr((""+ o[k]).length))
  return format;
}

Date.prototype.getNowDate = function() {
  var date = new Date();
  var sign1 = "-";
  var sign2 = ":";
  let year = date.getFullYear() // 年
  var month = date.getMonth() + 1; // 月
  var day  = date.getDate(); // 日
  var hour = date.getHours(); // 时
  var minutes = date.getMinutes(); // 分
  var seconds = date.getSeconds() //秒
  var mr = month.toString()
  var dr = day.toString()
  var hr = hour.toString()
  var mir = minutes.toString()
  var ser = seconds.toString()
  // 给一位数数据前面加 “0”
  if (month >= 1 && month <= 9) {
    mr = "0" + month;
  }
  if (day >= 0 && day <= 9) {
    dr = "0" + day;
  }
  if (hour >= 0 && hour <= 9) {
    hr = "0" + hour;
  }
  if (minutes >= 0 && minutes <= 9) {
    mir = "0" + minutes;
  }
  if (seconds >= 0 && seconds <= 9) {
    ser = "0" + seconds;
  }
  var currentdate = year + sign1 + mr + sign1 + dr + " " + hr + sign2 + mir + sign2 + ser;
  return currentdate;
}

//判断数组是否包含某个元素
Array.prototype.contains = function(target) {
  for(var i = 0; i < this.length; i++){
    if(target === this[i]){
        return true;
    }
  }
  return false
}

Array.prototype.remove = function(target) {
  const i = this.indexOf(target)
  this.splice(i,1)
}